
/*Entry Cost Analysis
STATA 14
January 12, 2017
Replicates Figure 3, Figure 4, Table 1, Table 2*/


cd  "C:\Users\ejm5\Dropbox\Rents_Asunder\CountryofOrigin\20160315_InternationaOrganization\Replication"
use  oecd_7years_working.dta, clear
log using entry.smcl, replace

/*Pause Turned On to Stop at Main Replication Figures and Tables*/
pause on


/*Drop all firms that entered very early to avoid recall bias.*/
drop if a1<2005


/*Figure 3*/
#delimit;
cibar c6, 
over1(treatment) over2(phase3) over3(oecd) level(90) 
graphopts(ytitle("Average Activities during Business Entry", size(medium) margin(medium)) note("Range bars=90% CI") scheme(s1mono))  barlabel(on) ;
graph save Figure3.gph, replace;
graph export Figure3.pdf, as(pdf) replace;
pause;


/*Figure 4*/
#delimit;
cibar c6  if country_id==25, 
over1(treatment) over2(phase3) level(90) 
graphopts(ytitle("", size(medium) margin(medium)) title("Japan") legend(ring(0) rows(2) position(11)) scheme(s1mono)) barlabel(on);
graph save JP.gph, replace;

#delimit;
cibar c6  if country_id==50, 
over1(treatment) over2(phase3) level(90) 
graphopts(ytitle("", size(medium) margin(medium)) title("South Korea") legend(off) scheme(s1mono)) barlabel(on);
graph save SK.gph, replace;

#delimit;
cibar c6  if country_id==56, 
over1(treatment) over2(phase3) level(90) 
graphopts(ytitle("", size(medium) margin(medium)) title("Taiwan") legend(off) scheme(s1mono)) barlabel(on);
graph save TW.gph, replace;


#delimit;
cibar c6  if country_id==47, 
over1(treatment) over2(phase3) level(90) 
graphopts(ytitle("", size(medium) margin(medium)) title("Singapore") legend(off) scheme(s1mono)) barlabel(on);
graph save SG.gph, replace;


#delimit;
cibar c6  if country_id==62,
over1(treatment) over2(phase3) level(90) 
graphopts(ytitle("", size(medium) margin(medium)) title("United States") legend(off) scheme(s1mono)) barlabel(on);
graph save US.gph, replace;

#delimit;
cibar c6  if country_id==9, 
over1(treatment) over2(phase3) level(90) 
graphopts(ytitle("", size(medium) margin(medium)) title("China") legend(off) scheme(s1mono)) barlabel(on);
graph save CH.gph, replace;


#delimit;
cibar c6  if country_id==61,
over1(treatment) over2(phase3) level(90) 
graphopts(ytitle("", size(medium) margin(medium)) title("United Kingdom") legend(off) scheme(s1mono)) barlabel(on);
graph save UK.gph, replace;

#delimit;
cibar c6  if country_id==32, 
over1(treatment) over2(phase3) level(90) 
graphopts(ytitle("", size(medium) margin(medium)) title("Malaysia") legend(off) scheme(s1mono)) barlabel(on);
graph save MY.gph, replace;



#delimit;
graph combine JP.gph SK.gph US.gph UK.gph, cols(4) xcommon ycommon imargin(tiny) title("   Signatories") scheme(s1mono);
graph save signatory.gph, replace;

#delimit;
graph combine TW.gph SG.gph CH.gph MY.gph, cols(4) xcommon ycommon imargin(tiny) title("   Non-Signatories") scheme(s1mono);
graph save nsignatory.gph, replace;

graph combine signatory.gph nsignatory.gph, rows(2) xcommon ycommon imargin(medsmall) scheme(s1mono)
subtitle("Activities during Business Entry", size(medium) orientation(vertical) position(9))
note("Range bars=90% CI");;
graph save Figure4.gph, replace;
graph export Figure4.pdf, as(pdf) replace;
pause;


/**********************************DESCRIPTIVES************************************/


/*Table 1: First Panel*/
#delimit;
mean c6, over(treatment);
pause;



/*********************************************************************************************************************************/
/*Table 2: Registration*/

/*Model 1*/
#delimit;
set more off;
xi: nbreg c6 if treatment==0 , cluster(pci_id);
predict ns_items;
generate bribe=c6-ns_items;
nl (bribe = {b0}) if treatment==1 , cluster(pci_id) vce(bootstrap, reps(1000)) ;
estimates store T2_Model1   ;
outreg2 using 20161125_DinD,  bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, No, Sector FE, No, Firm Countrols, No, Country Controls, No, Country FE, No,  Asia Big 4, No) replace;
drop ns_items bribe;

/*Model 2*/
#delimit;
set more off;
xi: nbreg c6 phase3 oecd inter_p3oecd  if treatment==0 , cluster(pci_id);
predict ns_items;
generate bribe=c6-ns_items;
nl (bribe = {b0}+{b1}*phase3+{b2}*oecd+{b3}*inter_p3oecd) if treatment==1 , cluster(pci_id)   variables (phase3 oecd inter_p3oecd ) vce(bootstrap, reps(1000));
#delimit;
estimates store T2_Model2;
mfx;
outreg2 using 20161125_DinD, mfx bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, No, Sector FE, No, Firm Countrols, No, Country Controls, No, Country FE, No,  Asia Big 4, No);
drop ns_items bribe;

/*Model 3*/
#delimit;
set more off;
xi: nbreg c6 y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd  if treatment==0 , cluster(pci_id);
predict ns_items;
generate bribe=c6-ns_items;
nl (bribe = {b0}+{b1}*y2+{b2}*y3+{b3}*y4+{b4}*y5+{b5}*y6+{b6}*y7+{b7}*phase3+{b8}*oecd+{b9}*inter_p3oecd) if treatment==1 , 
cluster(pci_id) vce(bootstrap, reps(1000))   variables (y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd);
estimates store T2_Model3;
mfx;
outreg2 using 20161125_DinD, mfx bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, Yes, Sector FE, No, Firm Countrols, No, Country Controls, No, Country FE, No,  Asia Big 4, No);
drop ns_items bribe;

/*Model 4*/
#delimit;
set more off;
xi: nbreg c6 y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5   if treatment==0 , cluster(pci_id);
predict ns_items;
generate bribe=c6-ns_items;
nl (bribe = {b0}+{b1}*y2+{b2}*y3+{b3}*y4+{b4}*y5+{b5}*y6+{b6}*y7+{b7}*phase3+{b8}*oecd+{b9}*inter_p3oecd+{b10}*a6_1+{b11}*a6_2+{b12}*a6_3+{b13}*a6_4+{b14}*a6_5) if treatment==1 , 
cluster(pci_id) vce(bootstrap, reps(1000))   variables (y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5);
estimates store T2_Model4;
mfx;
outreg2 using 20161125_DinD, mfx  bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, Yes, Sector FE, Yes, Firm Countrols, No, Country Controls, No, Country FE, No,  Asia Big 4, No);
drop ns_items bribe;


/*Model 5*/
#delimit;
set more off;
xi: nbreg c6 y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5 hundred  labor_est  d2  if treatment==0 , cluster(pci_id);
predict ns_items;
generate bribe=c6-ns_items;
nl (bribe = {b0}+{b1}*y2+{b2}*y3+{b3}*y4+{b4}*y5+{b5}*y6+{b6}*y7+{b7}*phase3+{b8}*oecd+{b9}*inter_p3oecd+{b10}*a6_1+{b11}*a6_2
+{b12}*a6_3+{b13}*a6_4+{b14}*a6_5+{b15}*hundred+{b16}*labor_est+{b17}*d2) if treatment==1 , 
cluster(pci_id) vce(bootstrap, reps(1000))   variables (y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5 hundred  labor_est  d2);
estimates store T2_Model5;
mfx;
outreg2 using 20161125_DinD, mfx  bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, Yes, Sector FE, Yes, Firm Countrols, Yes, Country Controls, No, Country FE, No,  Asia Big 4, No);

#delimit;
reg bribe y2 y3 y4 y5 y6 y7 i.phase3##i.oecd  a6_1 a6_2 a6_3 a6_4 a6_5 hundred  labor_est  d2, cluster(pci_id);
margins oecd, by(phase3);


drop ns_items bribe;



/*Model 6*/
#delimit;
set more off;
xi: nbreg c6 y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5 hundred  labor_est  d2 ln_gdp_pc   ln_pop p_polity2  if treatment==0 , cluster(pci_id);
predict ns_items;
generate bribe=c6-ns_items;
nl (bribe = {b0}+{b1}*y2+{b2}*y3+{b3}*y4+{b4}*y5+{b5}*y6+{b6}*y7+{b7}*phase3+{b8}*oecd+{b9}*inter_p3oecd+{b10}*a6_1+{b11}*a6_2+{b12}*a6_3+{b13}*a6_4+{b14}*a6_5
+{b15}*hundred+{b16}*labor_est+{b17}*d2+{b18}*ln_gdp_pc+{b19}*ln_pop+{b20}*p_polity2) if treatment==1 , 
cluster(pci_id) vce(bootstrap, reps(1000))   variables (y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5 hundred  labor_est  d2 ln_gdp_pc   ln_pop p_polity2);
estimates store T2_Model6;
mfx;
outreg2 using 20161125_DinD, mfx  bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, Yes, Sector FE, Yes, Firm Countrols, Yes, Country Controls, Yes, Country FE, No,  Asia Big 4, No);
drop ns_items bribe;

/*Model 7*/
#delimit;
set more off;
xi: areg c6 y2 y3 y4 y5 y6 y7 inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5  hundred  labor_est  d2 ln_gdp_pc   ln_pop p_polity2   i.a1  if treatment==0 ,  absorb(country_id);
predict ns_items;
generate bribe=c6-ns_items;
xi: areg bribe y2 y3 y4 y5 y6 y7 inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5  hundred  labor_est  d2 ln_gdp_pc   ln_pop p_polity2 i.a1  if treatment==1,   
absorb(country_id) vce(bootstrap, reps(1000));
estimates store T2_Model7;
outreg2 using 20161125_DinD, bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, Yes, Sector FE, Yes, Firm Countrols, Yes, Country Controls, No, Country FE, Yes,  Asia Big 4, No) excel;
drop ns_items bribe;


#delimit;
preserve; 
keep if country_id==25|country_id==50|country_id==47|country_id==56;

/*Model 8*/
set more off;
xi: nbreg c6 if treatment==0, cluster(pci_id);
predict ns_items;
generate bribe=c6-ns_items;
nl (bribe = {b0}) if treatment==1, cluster(pci_id) vce(bootstrap, reps(1000)); 
estimates store T2_Model8;   
outreg2 using 20161125_DinD,  bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, No, Sector FE, No, Firm Countrols, No, Country Controls, No, Country FE, No,  Asia Big 4, Yes);
drop ns_items bribe;
restore;

#delimit;
preserve; 
keep if country_id==25|country_id==50|country_id==47|country_id==56;

/*Model 9*/
set more off;
xi: nbreg c6 y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd  if treatment==0 , cluster(pci_id);
predict ns_items;
generate bribe=c6-ns_items;
nl (bribe = {b0}+{b1}*y2+{b2}*y3+{b3}*y4+{b4}*y5+{b5}*y6+{b6}*y7+{b7}*phase3+{b8}*oecd+{b9}*inter_p3oecd) if treatment==1 ,   cluster(pci_id) vce(bootstrap, reps(1000))   variables (y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd  );
estimates store T2_Model9;
mfx;
outreg2 using 20161125_DinD, mfx  bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, Yes, Sector FE, Yes, Firm Countrols, No, Country Controls, No, Country FE, No,  Asia Big 4, Yes);
drop ns_items bribe;
restore;

#delimit;
preserve; 
keep if country_id==25|country_id==50|country_id==47|country_id==56;

/*Model 10*/
#delimit;
set more off;
xi: nbreg c6 y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5 hundred  labor_est  d2  if treatment==0 , vce(bootstrap, reps(1000)) cluster(pci_id);
predict ns_items;
generate bribe=c6-ns_items;
nl (bribe = {b0}+{b1}*y2+{b2}*y3+{b3}*y4+{b4}*y5+{b5}*y6+{b6}*y7+{b7}*phase3+{b8}*oecd+{b9}*inter_p3oecd+{b10}*a6_1+{b11}*a6_2+{b12}*a6_3+{b13}*a6_4+{b14}*a6_5
+{b15}*hundred+{b16}*labor_est+{b17}*d2) if treatment==1 , 
  cluster(pci_id)   variables (y2 y3 y4 y5 y6 y7 phase3 oecd inter_p3oecd a6_1 a6_2 a6_3 a6_4 a6_5 hundred  labor_est  d2);
estimates store T2_Model10;
mfx;
outreg2 using 20161125_DinD, mfx  bdec(3) tdec(3) e(N N_clust rmse ll ) addtext(Survey Year FE, Yes, Sector FE, Yes, Firm Countrols, Yes, Country Controls, No, Country FE, No,  Asia Big 4, No) excel;
drop ns_items bribe;
pause;



/*LR TESTS*/
lrtest T2_Model1 T2_Model2, stats force;
lrtest T2_Model1 T2_Model3, stats force;
lrtest T2_Model1 T2_Model4, stats force;
lrtest T2_Model1 T2_Model5, stats force;
lrtest T2_Model1 T2_Model6, stats force;
lrtest T2_Model1 T2_Model7, stats force;
lrtest T2_Model8 T2_Model9, stats force;
lrtest T2_Model8 T2_Model10, stats force;
log close;











